<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>范例</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="pcre.constants.html">« 预定义常量</a></li>
      <li style="float: right;"><a href="pcre.pattern.html">PCRE模式 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.pcre.html">PCRE</a></li>
    <li>范例</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="pcre.examples" class="appendix">
 <h1>范例</h1>

 <p class="para">
  <div class="example" id="example-4719">
   <p><strong>示例 #1 合法模式示例</strong></p>
   <ul class="itemizedlist">
    <li class="listitem"><span class="simpara"><code class="literal">/&lt;\/\w+&gt;/</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">|(\d{3})-\d+|Sm</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">/^(?i)php[34]/</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">{^\s+(\s+)?$}</code></span></li>
   </ul>
  </div>
 </p>
 <p class="para">
  <div class="example" id="example-4720">
   <p><strong>示例 #2 非法模式示例</strong></p>
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      <code class="literal">/href=&#039;(.*)&#039;</code> - 缺失结束分隔符
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      <code class="literal">/\w+\s*\w+/J</code> - 未知模式修饰符&quot;J&quot;
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      <code class="literal">1-\d3-\d3-\d4|</code> - 缺失开始分隔符
     </span>
    </li>
   </ul>
  </div>
 </p>
</div>
</div></div></body></html>